// pages/newCard/newCard.js
var tuiwa = require("../../tuiwa.js");
Page({
  data: {
    swiper: {
      imgUrls: [],
      current: 0,
    },
    list: [],
    currentIndex: 0,
    widthProgress: 0,
    testLoadingLayerBg:false,
    testLoadingLayer: true,
  },
  onLoad: function (query) {
    if(!tt.getStorageSync('openId')){
      tuiwa.bindDyWx();
    }
     
    let imgUrl = JSON.parse(query.imgUrls)
    let imgUrls = 'swiper.imgUrls'
    let list = JSON.parse(query.list)
    var that = this;
    that.setData({
      [imgUrls]: imgUrl,
    })
    this.setData({
      list: list,
    })
    // setTimeout(() => {
    //   this.setData({
    //     testLoadingLayer: false,
    //     // testLoadingLayerBg:false,
    //   })
    // }, 4000)
    setTimeout(() => {
      this.setData({
        testLoadingLayerBg: true
      })
    }, 500)
  },
  bindload() {
    // setTimeout(() => {
    this.setData({
      testLoadingLayer: false
    })
    // }, 4000)
    // console.log('图片加载完毕')
  },
  onJump: function (e) {
    let current = this.data.currentIndex;
    let currentMap = this.data.swiper.imgUrls[current]
    let list = JSON.stringify(this.data.list)
    tt.navigateTo({
      // url: currentMap.url
      url: '/pages/newCard_show/newCard_show?images=' + currentMap.images
        + '&list=' + list
        + '&width=' + currentMap.width
        + '&height=' + currentMap.height
        + '&left=' + currentMap.left
        + '&top=' + currentMap.top
        + '&num=' + currentMap.num,
    });
    // console.log(currentMap.images, currentMap.width, currentMap.height, currentMap.top, currentMap.left, currentMap.num)
  },
  handleChange: function (e) {
    this.setData({
      currentIndex: e.detail.current
    })
  },
  back() {
    wx.navigateBack({
      delta: 1
    })
  },
})